feat: Add custom model support with AWS credentials #2538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for custom models that bypass Builder ID authentication and use AWS credentials directly, enabling enterprise users to leverage Amazon Q CLI with their existing AWS authentication infrastructure.
Motivation
Enterprise users need to use Amazon Q CLI with:
Changes
Core Features
custom:<region>:<model-id>
Technical Implementation
parse_custom_model()
function to extract region and model IDCustomModelHandler
for managing custom model logicUsage Examples
Bedrock-style model ID:
Q Developer model ID:
Set as default:
q settings chat.defaultModel "custom:us-east-1:CLAUDE_3_7_SONNET_20250219_V1_0"
Testing
✅ Tested with both Bedrock and Q Developer model ID formats
✅ Verified AWS credentials chain authentication
✅ Confirmed region extraction and configuration
✅ Validated model ID mapping
✅ Tested interactive and non-interactive modes
Files Changed
crates/chat-cli/src/api_client/custom_model.rs
- New custom model handlercrates/chat-cli/src/api_client/mod.rs
- API client modificationscrates/chat-cli/src/cli/chat/cli/model.rs
- Model parsing and mappingcrates/chat-cli/src/cli/chat/mod.rs
- Chat session enhancementscrates/chat-cli/src/cli/mod.rs
- Authentication bypass logicdocs/CUSTOM_MODELS.md
- Comprehensive documentationBenefits
Backward Compatibility
✅ All existing functionality preserved
✅ Standard models continue to work as before
✅ Builder ID authentication still used for non-custom models
🤖 Generated with Claude Code